package baseFee

import (
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
	"miners-monitor/models/common"
)

type BaseFeeAoModel struct {
	common.BaseModel
	CommonFunc common.CommonFunc
	BaseFeeDb   BaseFeeDbModel
}

func (this *BaseFeeAoModel) FindOne(filter BaseFee, opts *options.FindOneOptions) BaseFee {
	mongoResult := this.BaseFeeDb.FindOne(filter, opts)
	result := BaseFee{}
	err := mongoResult.Decode(&result)
	if err == mongo.ErrNoDocuments {
		return BaseFee{}
	} else if err != nil {
		panic(err)
	}
	return result
}

func (this *BaseFeeAoModel) Upsert(update BaseFee) {
	this.BaseFeeDb.Upsert(update)
}
